fix(mcp): improve not-found errors to suggest corresponding list_* tools#39919
fix(mcp): improve not-found errors to suggest corresponding list_* tools#39919aminghadersohi wants to merge 1 commit intoapache:masterfrom
Conversation
…tools When MCP tools return "not found" errors for database, chart, dataset, or dashboard IDs, include recovery guidance pointing to the appropriate list tool (list_databases, list_charts, list_datasets, list_dashboards). Affected tools: execute_sql, open_sql_lab_with_context, query_dataset, get_chart_data, get_chart_preview, update_chart, add_chart_to_existing_dashboard, generate_dashboard
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #39919 +/- ##
=======================================
Coverage 63.88% 63.88%
=======================================
Files 2583 2583
Lines 136604 136604
Branches 31502 31502
=======================================
Hits 87276 87276
Misses 47812 47812
Partials 1516 1516
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code Review Agent Run #e03ef2Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
When MCP tools return "not found" errors for invalid resource IDs (database, chart, dataset, dashboard), the LLM has no signal to recover. This change adds actionable recovery guidance to all "not found" error messages in MCP tools.
Before:
After:
Affected tools:
execute_sql— database not found → suggestlist_databasesopen_sql_lab_with_context— database not found → suggestlist_databasesquery_dataset— dataset not found → suggestlist_datasetsget_chart_data— chart not found → suggestlist_chartsget_chart_preview— chart not found → suggestlist_chartsupdate_chart— chart not found → suggestlist_chartsadd_chart_to_existing_dashboard— dashboard/chart not found → suggestlist_dashboards/list_chartsgenerate_dashboard— charts not found → suggestlist_chartsBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — error message text change only.
TESTING INSTRUCTIONS
execute_sqlwith an invaliddatabase_id(e.g.,-1)Use list_databases to get valid database IDs.Unit tests updated in
tests/unit_tests/mcp_service/sql_lab/tool/test_open_sql_lab_with_context.py.ADDITIONAL INFORMATION